﻿using AppService.IService.ICargo_mentSrevice;
using Domain.Entity.Basic_information;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace WebAPI.Controllers.Cargo_mentControllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class Cargo_mentController : ControllerBase
    {
        public Cargo_mentController(ICargo_mentSrevice cargo_MentSrevice)
        {
            Cargo_MentSrevice = cargo_MentSrevice;
        }

        public ICargo_mentSrevice Cargo_MentSrevice { get; }

        /// <summary>
        /// 查询未删除的数据
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public List<Cargo_ment> GetCargo_s(int currentPage, int PageSize)
        {
            return Cargo_MentSrevice.GetCargo_s(currentPage, PageSize);
        }

        /// <summary>
        /// 查询总数
        /// </summary>
        /// <param name="time"></param>
        /// <param name="Cg_name"></param>
        /// <returns></returns>
        [HttpGet]
        public int GetCount(string? time, string? Cg_name)
        {
            return Cargo_MentSrevice.Count(time, Cg_name);
        }

        /// <summary>
        /// 根据创建时间的货品名称查询数据
        /// </summary>
        /// <param name="time"></param>
        /// <param name="Cg_name"></param>
        /// <param name="currentPage"></param>
        /// <param name="PageSize"></param>
        /// <returns></returns>
        [HttpGet]
        public List<Cargo_ment> GetCargo_Ment_time(string? time, string? Cg_name, int currentPage, int PageSize)
        {
            return Cargo_MentSrevice.GetCargo_ment_time(time, Cg_name, currentPage, PageSize);
        }

        /// <summary>
        /// 根据id更改删除表示状态进行逻辑删除
        /// </summary>
        /// <param name="Cg_id"></param>
        /// <returns></returns>
        [HttpDelete]
        public bool Delete(int Cg_id)
        {
            return Cargo_MentSrevice.Delete(Cg_id);
        }

        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="cargo_Ment"></param>
        /// <returns></returns>
        [HttpPost]
        public bool Add(Cargo_ment? cargo_Ment)
        {
            return Cargo_MentSrevice.Add(cargo_Ment);
        }

        /// <summary>
        /// 根据id查询
        /// </summary>
        /// <param name="Cg_id"></param>
        /// <returns></returns>
        [HttpGet("{Cg_id}")]
        public List<Cargo_ment> cargo_Ments_id(int Cg_id)
        {
            return Cargo_MentSrevice.GetCargo_Ments_id(Cg_id);
        }

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="cargo_Ment"></param>
        /// <returns></returns>
        [HttpPut]
        public bool Update([FromBody] Cargo_ment? cargo_Ment)
        {
            return Cargo_MentSrevice.Update(cargo_Ment);
        }

    }
}
